<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="翻译平台、翻译网站、找翻译、找人翻译、法语翻译、英语翻译、日语翻译、德语翻译、意大利语翻译、俄罗斯语、翻译人员、成都翻译、成都翻译员" />
<meta name="description" content="众译，助推翻译事业，选择最佳翻译人员，最迅速、最便捷的网络翻译平台。" />
<title>众译-可信赖的翻译平台-登陆页面</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/css.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/jquery.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function() {
	$("#login_button").bind("click", preValidate);
	$("#chageCode").bind("click", changeCodeHandler);
	$(document).bind("keydown", hotKeyHandler);
});

function changeCodeHandler(event) {
	var src = $("#authCodeImg").attr("src");
	var end = src.indexOf("?");
	if (end > -1) {
		src = src.substring(0, end);
	}
	$("#authCodeImg").attr("src", src + "?random=" + Math.random());
}

function hotKeyHandler(event) {
	switch (event.keyCode) {
	case 13:
		$("#login_button").focus();
		//$("#login_button").click();
		break;
	default:
		break;
	}
}

function addMessage(currentNode, preBrother, message) {
	if ((currentNode.attr("name") + "tips") == preBrother.attr("id")) {
		preBrother.find(".error_tips").text(message);
	} else {
		var tips = "<tr id='" + currentNode.attr("name") + "tips'>" +
			"<td></td>" +
			"<td><em class=\"error_tips\">"+message+"</em></td>" +
			"</tr>";
			preBrother.after(tips);
	}
}

function preValidate() {
	var result = true;
	
	$(":input[alt='necessary']").each(function (){
		
		var currentNode = $(this);
		
		var preBrother = currentNode.parent().parent().prev();
		
		var nodeAttrName = currentNode.attr("name");
		
		var nodeValue = currentNode.val();
		
		switch (nodeAttrName) {
			case "username":
				if (nodeValue.isEmpty()) {
					addMessage(currentNode, preBrother, "<s:text name='error.accout'/>");
					result = false;
				} else if (!nodeValue.isAlpha()) {
					addMessage(currentNode, preBrother, "<s:text name='error.accout.illegal'/>");
					result = false;
				} else {
					if ((currentNode.attr("name") + "tips") == preBrother.attr("id")) {
						preBrother.remove();
					}
				}
				break;
			case "passwd":
				if (nodeValue.isEmpty()) {
					addMessage(currentNode, preBrother, "<s:text name='error.password'/>");
					result = false;
				} else if (!nodeValue.isAlpha()) {
					addMessage(currentNode, preBrother, "<s:text name='error.password.illegal'/>");
					result = false;
				} else {
					if ((currentNode.attr("name") + "tips") == preBrother.attr("id")) {
						preBrother.remove();
					}
				}
				break;
			case "authCode":
				if (!nodeValue.isAuthCode()) {
					addMessage(currentNode, preBrother, "<s:text name='error.authcode'/>");
					result = false;
				} else {
					if ((currentNode.attr("name") + "tips") == preBrother.attr("id")) {
						preBrother.remove();
					}
				}
				break;
		}
	});
	
	if (result) {
		$("#login_form").submit();
		$("#login_button").unbind("click", preValidate);
	}
}
</script>
</head>
<body>
<div class="layout">
<jsp:include page="/include/head/top.jsp"/>
<jsp:include page="/include/head/top_nav.jsp"/>
<div class="step">翻译步骤：查找译员->与译员沟通项目细节->预付款到众译->项目洽谈成功->收取译稿并验收->双方评价，项目完结。</div>
<div class="content">
<div class="login">
<form action="<%=request.getContextPath() %>/passport/login_execute" enctype="application/x-www-form-urlencoded" method="post" id="login_form">
<table>
	<tr>
		<td rowspan="5" width="300" valign="top">
		<p>众译是一个以翻译为目的的威客平台，主要为译员和翻译需求方提供便利的网站。</p>
		</td>
		<td></td>
		<td>
		<h1>用户登陆</h1>
		</td>
	</tr>
		<s:if test="%{hasFieldErrors('username')}">
		<tr id="usernametips">
			<td></td>
			<td><em class="error_tips"><s:fielderror fieldName="username" /></em></td>
		</tr>
	</s:if>
	<tr>
		<td width="200" align="right">用户名：</td>
		<td><input type="text" class="intxt" name="username" value="<s:property value='username'/>" alt="necessary"/></td>
	</tr>
	<s:if test="%{hasFieldErrors('passwd')}">
		<tr id="passwdtips">
			<td></td>
			<td><em class="error_tips"><s:fielderror fieldName="passwd" /></em></td>
		</tr>
	</s:if>
	<tr>
		<td align="right">密码：</td>
		<td><input type="password" class="intxt" name="passwd" value="<s:property value='passwd'/>" alt="necessary"/></td>
	</tr>
	<s:if test="%{hasFieldErrors('authCode')}">
		<tr id="authCodetips">
			<td></td>
			<td><em class="error_tips"><s:fielderror fieldName="authCode" /></em></td>
		</tr>
	</s:if>
	<tr>
		<td align="right">验证码：</td>
		<td>
		<input type="text" class="intxt" alt="necessary" name="authCode"/><br/>
		<i>*</i><span>请输入右边图片中的字符(不区分大小写)</span>
		<img id="authCodeImg" src="<%=request.getContextPath() %>/AuthCodeServlet" alt="验证码" />
		<a href="javascript:void(0)" id="chageCode">看不清?换一个?</a>
		</td>
	</tr>
	<tr>
		<td align="right"></td>
		<td><input type="checkbox" checked="checked" /><label>记住用户名和密码</label></td>
	</tr>
	<tr>
		<td></td>
		<td>
		<input type="hidden" value="<s:property value="#parameters.jumpurl"/>" name="jumpurl"/>
		<input value="登陆" id="login_button" type="button"/>
		<a href="#">忘记密码?</a></td>
	</tr>
</table>
</form>
</div>
</div>
<jsp:include page="/include/foot/foot.jsp" />
</div>
</body>
</html>
